#ifndef _CBROWSERWINDOW_H_
#define _CBROWSERWINDOW_H_

#include <buola/gui/cwindow.h>
#include <buola/io/curi.h>
#include <buola/widgets/clistbox.h>
#include <buola/widgets/ctreebox.h>
#include <buola/widgets/cfilelist.h>
#include <buola/widgets/cdirtree.h>

namespace buola { namespace browser {

class CBrowserApp;
    
class CBrowserWindow : public gui::CWindow
{
public:
    enum ENav
    {
        NAV_HOME,
        NAV_UP,
        NAV_BACK,
        NAV_FORWARD
    };

    CBrowserWindow(CBrowserApp *pApp);

    void SetWorkingURI(const io::CURI&,bool=true,bool=true);
    const io::CURI &GetWorkingURI() {   return mURI;    }

    void Navigate(ENav pWhere);

////////////// event handling //////////////
    void OnListFillMenu(gui::PMenu pMenu);
    void OnTreeFillMenu(gui::PMenu pMenu);
    void OnTreeSelected(gui::CTreeBox::SNode *pNode);
    void OnListDblClick(gui::CListBox::SItem *pItem);
    void OnListSelected();
    void OnIntAction(gui::TID pAction,const io::CURI &pURI);
    void OnShow();

protected:
    CBrowserApp *mApp;
    
    io::CURI mURI;
    io::CURI mStartURI;

    gui::PEditBox mEdit;
    gui::PDirTree mDirTree;
    gui::PFileList mFileList;
    gui::PToolBar mToolBar;
    gui::PStatusBar mStatusBar;

    std::vector<io::CURI> mHistory;
    int mHistoryPos;
};

typedef intrusive_ptr<CBrowserWindow> PBrowserWindow;

/*namespace browser*/ } /*namespace buola*/ }

#endif
